|
|
|
|
|
|
|
If you have multiple public classes defined in a DLL, you can access all of them: |
|
|
|
|
|
|
|
|
Dim objCEO As New EmployeeDLL.clsExecutive
Dim objDilbert As New EmployeeDLL.clsEngineer |
|
|
|
|
|
|
|
|
Note that as you write code that uses these external classes, all the same editor features (such as parameter lists) are available in the Visual Basic editing window. |
|
|
|
|
|
|
|
|
Setting the Instancing Property |
|
|
|
|
|
|
|
|
In ActiveX DLL and ActiveX EXE projects, the Properties window for a class module has an extra property, the Instancing property, which is not available in a Standard EXE project. This property determines how instances of a class are created; the options vary for different project types. While learning the basics of classes and OOP, you can forget about this property and experiment with a Standard EXE project. However, this property is usually set during the creation of a class, so I mention it here. Table 16.1 describes the settings of the Instancing property. |
|
|
|
|
| Table 16.1 Using the Instancing Property | | Value | Name | Components | Description | | 1 | Private | EXE and DLL | The class cannot be accessed from outside the current project. | | 2 | PublicNot Creatable | EXE and DLL | Instances of the class can be created only within the project that defines the class. However, other applications can access instances after they are created. | | 3 | SingleUse | EXE only | Each time a new instance of a class is created, a new copy of the EXE containing the class is started. | | 4 | GlobalSingleUse | EXE only | Like SingleUse, but it makes the properties and methods appear as global variables and preocedures in the client program. | | 5 | MultiUse | EXE and DLL | Other applications can create any number of instances of the class, and only one copy of the program containing the class is started. ActiveX DLL projects generally use this setting. | | 6 | GlobalMultiUse | EXE and DLL | Like MultiUse, but it makes the properties and methods appear as global variables and procedures in the client program. |
|
|
|
|
|
|
Another way to look at the information in the preceding table is to think of EXE files versus DLL files. An ActiveX DLL file is intended to be a shared component, meaning the same |
|
|
|
|
|